﻿@using hc.epm.DataModel.Business;
@using System.Collections.Generic;
@model IEnumerable<Epm_OilStation>
@{
    ViewBag.Title = "加油站列表";
    Layout = "~/Views/Shared/_LayoutHc.cshtml";
}

<div class="content-right date-wrap fl c">
    <div class="search mt5">
        <form class="layui-form" action="" method="get">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">名称 : </label>
                    <div class="layui-input-inline"><input type="text" name="name" id="name" placeholder="请输入加油站名称" autocomplete="off" class="layui-input" value="@ViewBag.name" /></div>
                </div>
                <input type="submit" class="layui-btn layui-btn-radius layui-btn-warm" lay-filter="search" value="搜 索" />
            </div>
        </form>
    </div>
    <div class="main mt5">
        <table class="layui-table">
            <thead>
                <tr>
                    <th width="80" class="table-center">序号</th>
                    <th width="20%" class="table-center">编号</th>
                    <th width="30%" class="table-center">名称</th>
                    @*<th class="table-center">简介</th>*@
                    <th width="40%" class="table-center">地址</th>
                    <th width="90" class="table-center">操作</th>
                </tr>
            </thead>
            <tbody>
                @{
                    int index = 0;
                }
                @if (Model != null && Model.Count() > 0)
                {
                    foreach (var item in Model)
                    {
                        index++;
                        <tr>
                            <td class="table-center">@index</td>
                            <td class="table-center">@item.Code</td>
                            <td class="table-center">@item.Name</td>
                            @*<td class="table-center">@item.Description</td>*@
                            <td class="table-center">@item.Address</td>
                            <td class="table-center">
                                <a href="javascript:;"  class="detail-link" data-itemid="@item.SId" title="详情"><i class="glyphicon glyphicon-list-alt handle-blue"></i></a>
                            </td>
                        </tr>
                    }
                }
                else
                {
                    <tr>
                        <td colspan="5" class="table-center">
                            暂无数据
                        </td>
                    </tr>
                }
            </tbody>
        </table>
        <div id="page"></div>
    </div>
</div>
<script>
    //若无数据隐藏分页组件
    if ('@ViewBag.Total' == 0) {
        $("#page").hide();
    }
    layui.use(['layer', 'form', 'element', 'laypage'], function () {
        var layer = layui.layer, form = layui.form, element = layui.element, $ = layui.jquery, laypage = layui.laypage;
        //分页
        laypage.render({
            elem: 'page',
            count: '@ViewBag.Total',
            curr: '@ViewBag.pageIndex',
            layout: ['prev', 'page', 'next', 'skip', 'count', ],
            jump: function (obj, first) {
                if (!first) {
                    //得到了当前页，用于向服务端请求对应数据
                    var curr = obj.curr;
                    var search = $("form").serialize();
                    window.location.href = "/HcOilStation/Index?pageIndex=" + curr + "&" + search;
                }
            }
        });
    });

    //加油站详情
    $(".detail-link").click(function () {
        var id = $(this).data("itemid");
        layer.open({
            type: 2,
            title: GetLayerTitle("加油站详情"),
            shadeClose: false, //点击遮罩关闭层
            area: [BigLayerWidth, '600px'],
            content: '/HcOilStation/Detail?id=' + id,
        });
    });
</script>
